package com.smarthome.web.property.controller.workingmonitor;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smarthome.core.workingmonitor.UserLogService;
import com.smarthome.domain.bean.ShUserLog;
import com.smarthome.domain.vo.boss.Combobox;
import com.smarthome.domain.vo.boss.DataGrid;
import com.smarthome.domain.vo.boss.PageHelper;
import com.smarthome.domain.vo.boss.TimeRange;
import com.smarthome.web.property.utils.UserHolder;

/**
 * 管理员日志控制类
 * @author cyj
 *
 */
@Controller
@RequestMapping("/userLogController")
public class UserLogController {

    @Resource
    private UserLogService userLogService;
    

    /**
     * 
    * dataGrid(获取管理员数据表格)
    * @Title: dataGrid
    * @Description: TODO
    * @param userLog
    * @param page
    * @param request
    * @return
    * DataGrid
    * @throws
    * @author cyj
    * @date 2015年9月11日 上午11:43:11
     */
    @RequestMapping("/dataGrid")
    @ResponseBody
    public DataGrid dataGrid(ShUserLog userLog, PageHelper page,TimeRange timeRange) {
    	if(timeRange.getStartGmtCreate() != null) {
    		userLog.addQueryData("startGmtCreate", timeRange.getStartGmtCreate());
    	}
    	if(timeRange.getEndGmtCreate() != null) {
    		userLog.addQueryData("endGmtCreate", timeRange.getEndGmtCreate());
    	}
    	userLog.setResidenceId(UserHolder.getCurrentResidenceId());
        return userLogService.dataGrid(userLog, page);
    }

    /**
     * 
    * @Title: typeCombobox 
    * @Description: TODO(获取管理员日志类型combobox数据) 
    * @return
    * List<Combobox>
    * @throws 
    * @author cyj
     */
    @RequestMapping("/typeCombobox")
    @ResponseBody
    public List<Combobox> typeCombobox() {
        return userLogService.typeCombobox(false);
    }
}
